﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace BussinessLayer
{
    public class tblDoanvien_thuongphat
    {
        DataLayer.Data odata = new DataLayer.Data();
        public DataTable Select()
        {
            return odata.view_text("SELECT * from doanvien_thuongphat");
        }

        public void Insert(int id, int hocky, string namhoc, int diem, bool thuong, string lydo)
        {
            SqlParameter[] sp = new SqlParameter[8];
            sp[0] = new SqlParameter("@dvtp_id", -1);
            sp[1] = new SqlParameter("@id", id);
            sp[2] = new SqlParameter("@hocky", hocky);
            sp[3] = new SqlParameter("@namhoc", namhoc);
            sp[4] = new SqlParameter("@diem", diem);
            sp[5] = new SqlParameter("@thuong", thuong);
            sp[6] = new SqlParameter("@lydo", lydo);
            sp[7] = new SqlParameter("@type", 1);
            odata.proc_TS("tblDoanvien_thuongphat", sp);
        }
        public void Update(int dvtp_id, int id, int hocky, string namhoc, int diem, bool thuong, string lydo)
        {
            SqlParameter[] sp = new SqlParameter[8];
            sp[0] = new SqlParameter("@dvtp_id", dvtp_id);
            sp[1] = new SqlParameter("@id", id);
            sp[2] = new SqlParameter("@hocky", hocky);
            sp[3] = new SqlParameter("@namhoc", namhoc);
            sp[4] = new SqlParameter("@diem", diem);
            sp[5] = new SqlParameter("@thuong", thuong);
            sp[6] = new SqlParameter("@lydo", lydo);
            sp[7] = new SqlParameter("@type", 2);
            odata.proc_TS("tblDoanvien_thuongphat", sp);
        }
        public void Delete(int dvtp_id)
        {
            SqlParameter[] sp = new SqlParameter[8];
            sp[0] = new SqlParameter("@dvtp_id", dvtp_id);
            sp[1] = new SqlParameter("@id", 1);
            sp[2] = new SqlParameter("@hocky", 1);
            sp[3] = new SqlParameter("@namhoc", "");
            sp[4] = new SqlParameter("@diem", 1);
            sp[5] = new SqlParameter("@thuong", true);
            sp[6] = new SqlParameter("@lydo", "");
            sp[7] = new SqlParameter("@type", 3);
            odata.proc_TS("tblDoanvien_thuongphat", sp);
        }
    }
}
